package cn.roderick;

import cn.roderick.aop.ICustomer;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.ApplicationContext;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableAutoConfiguration
@ComponentScan
@EnableTransactionManagement
public class WebApplication {

//    @Bean
//    public PlatformTransactionManager transactionManager() {
//        return new DataSourceTransactionManager   (dataSource());
//    }

    public static void main(String[] args)  throws Exception {
        //SpringApplication springApplication = new SpringApplication(WebApplication.class);
        /**禁止自动重启*/
        //System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(WebApplication.class, args);
//        testAop();
    }

    /**
     *
     */
    public static void testAop(){
        ApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] { "spring/SpringAOPAspectJ.xml" });
        ICustomer customer =(ICustomer)appContext.getBean("customer");
        customer.addCustomer();
        System.out.println("-------------------------------------------");
        customer.deleteCustomer();
    }
}